<%= form_for(@contact) do |f| %>
  <% if @contact.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@contact.errors.count, "error") %> prohibited this contact from being saved:</h2>

      <ul>
      <% @contact.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class='form-inputs'>
    <div class="form-group">
      <%= f.label :firstname %><br>
      <%= f.text_field :firstname %>
    </div>
    <div class="form-group">
      <%= f.label :lastname %><br>
      <%= f.text_field :lastname %>
    </div>
    <div class="form-group">
      <%= f.label :email %><br>
      <%= f.text_field :email %>
    </div>
    <%= f.fields_for :phones do |builder| %>
      <div class="form-group">
        <%= builder.hidden_field :phone_type %>
        <%= builder.label :phone, "#{builder.object.phone_type.capitalize} phone" %><br>
        <%= builder.text_field :phone %>
      </div>
    <% end %>
  </div>
  <div class="form-actions">
    <%= f.submit nil, class: 'btn btn-primary' %>
  </div>
<% end %>
